﻿//计算员工薪资
var fnCalcSalary = function () {
    $("#yui-gen0-button").text("计算");
    document.getElementById("dialog1_h").innerHTML = "计算员工薪资";
    document.getElementById("EditUIWindow").src = "../EHR/hrCalcSalary.aspx?r=" + Math.random();
    SetDWH(400, 300, YAHOO.example.container.dialog1);
    YAHOO.example.container.dialog1.show();
};

//计算部门员工薪资
var fnCalcDeptSalary = function () {
    var funId = getPar1("functionID");
    var token = funId.split("#");
    var deptId = token[1];
    var url = "../Extend/AjaxData/jsonlist.aspx?entity=DatDepartment&condition=DeptID='" + deptId + "'";
    $.get(url, function (d, s) {
        var list = eval("(" + d + ")");
        if (list.total > 0) {
            for (var o in list.rows) {
                var deptId = list.rows[o].DeptID;
                var deptName = list.rows[o].DeptName;
                var deptpath = list.rows[o].DeptPath;
                if (typeof (deptName) != "undefined" && deptpath.length > 8) {
                    $("#yui-gen0-button").text("计算");
                    document.getElementById("dialog1_h").innerHTML = "计算部门员工薪资";
                    document.getElementById("EditUIWindow").src = encodeURI("../EHR/hrCalcSalary.aspx?deptId=" + deptId + "&deptName=" + deptName + "&flag=1&r=" + Math.random());
                    SetDWH(400, 300, YAHOO.example.container.dialog1);
                    YAHOO.example.container.dialog1.show();
                    break;
                }
                else {
                    alert("请选择董事会以下的部门!");
                }
            }
        }
    });
};

//查看明细
var fnViewDeail = function (elCell, oRecord, oColumn, sData) {
    //debugger;
    elCell.innerHTML = "<a href=\"#\" onclick=\"javascript:fnOpenLink('" + oRecord.getData("EmployeeCode") + "','" + oRecord.getData("CName") + "','" + oRecord.getData("YearMonth") + "');\">" + sData + "</a>";
};


//打开链接
var fnOpenLink = function (empCode, empName, yearMonth) {
    var pagetitle = "查看【" + empName + "】" + yearMonth + "考勤明细";
    parent._employeeTitle = pagetitle;
    var url = "../Extend/YUIDataTableList.aspx?r=" + Math.random() + "&entity=V_wkWorkResultSalMonth" + "&condition=EmployeeCode='" + empCode + "' and YearMonth='" + yearMonth + "'";
    parent.addTabs(pagetitle, encodeURI(url));
    parent.NeedRefreshPage = this;
}

//查看佣金明细
var fnViewSalCommissionItem = function(elCell, oRecord, oColumn, sData) {
    elCell.innerHTML = "<a href=\"#\" onclick=\"javascript:fnOpenCommissionLink('" + oRecord.getData("EmployeeCode") + "','" + oRecord.getData("CName") + "','" + oRecord.getData("YearMonth") + "');\">" + sData + "</a>";
}

var fnOpenCommissionLink = function (empCode, empName, yearMonth) {
    var pagetitle = "查看【" + empName + "】" + yearMonth + "佣金明细";
    parent._employeeTitle = pagetitle;
    var y =parseInt( yearMonth.substr(0, 4));
    var m = parseInt(yearMonth.substr(5, 2));
    var url = "../Extend/YUIDataTableList.aspx?functionID=c314f6bc-db41-4443-9bb2-dd8b8183acff&r=" + Math.random() + "&entity=V_salCommissionItem" + "&condition=EmployeeCode='" + empCode + "' and Year='" + y + "' and Month='" + m+"'";
    parent.addTabs(pagetitle, encodeURI(url));
    parent.NeedRefreshPage = this;
}


